﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.IO;
using System.Windows.Forms;

namespace PenLiveUpdate {
    public partial class FrmComplateDownload : Form {

        private AutoUpdater au;
        private List<DownloadFileInfo> downloadFileList = null;
        private List<FileInfo> deleteFileList = null; //需删除的文件列表

        public FrmComplateDownload ( AutoUpdater au, List<DownloadFileInfo> downloadFileList, List<FileInfo> deleteFileList ) {
            InitializeComponent( );

            this.au = au;
            this.downloadFileList = downloadFileList;
            this.deleteFileList = deleteFileList;
        }

        private void FrmComplateDownload_Load ( object sender, EventArgs e ) {

            btnOK.Enabled = false;

            foreach (DownloadFileInfo dfile in this.downloadFileList) {

                if (File.Exists(dfile.FileName))
                    File.Delete(dfile.FileName);
                File.Move(au.TheFolderPath + @"\" + dfile.FileName, dfile.FileName);
            }
            foreach (FileInfo deletFile in this.deleteFileList){

                File.Delete(deletFile.Path);
            }

            lblState.Text = "配置完成，请点击完成按钮。";
            btnOK.Enabled = true;
        }

        private void btnOK_Click ( object sender, EventArgs e ) {

         //   this.DialogResult = DialogResult.OK;
            this.Close( );
        }
    }
}
